<template>
  <div class="popup">
    <div class="main">
      <div class="main-header">
        <p>视频榜单</p>
        <i class="iconfont icon-guanbi"></i>
      </div>
      <div class="detail">
        <div class="toggle flex-between flex-align-items-center">
          <div class="tabs flex flex-align-items-center">
            <template v-for="(item, index) in rankPartTabs">
              <p v-if="index > 0 || (index === 0 && type != 3)" class="pointer font-12"
                :class="{ active: item === form.tab }" @click="tabChange(item)">{{ item }}</p>
            </template>
          </div>
        </div>
        <rank-list :list="list" :tab="form.tab" :type="type"></rank-list>
      </div>
      <div class="pagination flex flex-align-items-center" style="justify-content: end;height: 64px;">
        <el-pagination :page-sizes="[10, 20, 50, 100]" layout="prev, pager, next, total" :total="form.total" />
      </div>
    </div>
  </div>
</template>

<script setup>
import RankList from './rankList.vue';
import { defineProps, ref } from 'vue';

const props = defineProps(['type']);

const rankPartTabs = ['曝光量排行', '点赞量排行', '评论量排行', '互动率排行'];

const form = ref({
  tab: props.type != 3 ? '曝光量排行' : '点赞量排行',
  total: 100
});
const list = ref([
  {
    id: 1,
    img: 'https://img-cdn.wotokol.com/images/1/video/4736EED9B04FC2D6079FEC861A9932C5FC9BBDECF2467655034AAF38AB138E889553A0CBFD2BA62A36864E5DDC828BEDA33E1A8AFC9FED0255CEA027332A1ED5.jpg',
    name: 'xxxxx',
    time: '2023-12-16',
    count: 1165465,
    rate: '55%'
  }
]);

const tabChange = e => {
  if (form.value.tab !== e) {
    form.value.tab = e;
  }
}
</script>

<style lang="less" scoped>
.main {
  position: absolute;
  right: 0;
  top: 0;
  z-index: 10;
  width: 1100px;
  height: 100%;
  background: #fff;

  .detail {
    height: calc(100vh - 116px);
    overflow-y: auto;
    padding: 24px;
  }
}

.toggle {
  .tabs {
    height: 44px;
    border-radius: 10px;
    border: 1px solid #f2f2f2;
    padding: 6px;

    p {
      width: 82px;
      height: 30px;
      color: #666;
      border-radius: 8px;
      border: 1px solid transparent;
      line-height: 28px;
      text-align: center;

      &.active {
        color: @main-color;
        border-color: @main-color;
        font-weight: bold;
      }
    }
  }

  .toggle-btn {
    color: @main-color;

    i {
      font-size: 14px;
      color: @main-color;
      margin-left: 4px;
    }
  }
}

.pagination {
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: 10;
  width: 100%;
  background: #fff;
  padding: 0 24px;
}
</style>